#ifndef _WINSOCK2SERVERSOCKET_H
#define _WINSOCK2SERVERSOCKET_H

#pragma once
#include "ServerSocket.h"
#include "NetworkException.h"
#include <winsock2.h>
#include <ws2tcpip.h>
#include <string>
#include <iostream>
#include <sstream>

using namespace std;

namespace net
{
class Winsock2ServerSocket : public ServerSocket
{
public:
	virtual ~Winsock2ServerSocket(void);
	virtual int doBind(void) throw (NetworkException);
	virtual int doListen(void) throw (NetworkException);
	virtual SOCKET doAccept(void) throw (NetworkException);
	virtual void doClose(void);
	virtual void setOption(OptionLevel, OptionName) throw (NetworkException);
	virtual string toString(void);
	friend class Winsock2SocketFactory;
private:
	Winsock2ServerSocket(int);
	string getSocketOptionReadable(int);
	string getSocketLevelReadable(int);
	struct addrinfo* obtainedAddress;
    struct addrinfo hints;
	SOCKET listenSocket;
	int portNumber;
};
};

#endif
